package Interceptor;

import com.jfinal.core.Controller;
import com.jfinal.validate.Validator;
public class TopicFormValidator  extends Validator {
    @Override
    protected void validate(Controller controller) {
        String title = controller.getPara("title");
        if (title.isEmpty()) {
            addError("error", "主题名称不为空");//adderror方法  一旦发生错误，就跳到addError方法中
        }
    }

    @Override
    protected void handleError(Controller controller) {
        controller.renderHtml("名称不能为空" + "<br><a href='/topic'>返回主题列表</a>");
    }
}
